package action

import (

	"net/http"
	"html/template"
	"signaling/src/framework"
	"fmt"
)

type xrtcClientPushAction struct {}

func NewXrtcClientPushAction() *xrtcClientPushAction {


	return &xrtcClientPushAction{}

}

func (*xrtcClientPushAction) Execute(w http.ResponseWriter ,cr *framework.ComRequest) {


	// fmt.Println("hello xtrclient push action")
	r := cr.R
	t,err := template.ParseFiles(framework.GetStaticDir() + "/template/push.tpl")
	if err != nil {
		fmt.Println(err)
		writeHtmlErrorResponse(w,http.StatusNotFound,"404- Not Found")
		return 
	}

	//获取请求的动态参数
	request := make(map[string]string)
	for k ,v :=range r.Form {
		request[k] = v[0]
	}
	err = t.Execute(w,request)
	if err != nil {
		fmt.Println(err)
		writeHtmlErrorResponse(w,http.StatusNotFound,"404 - Not Found")
		return
	}

}